package com.wenda.homeschooedu.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;
import com.wenda.homeschooedu.biz.ExamPlanManager;

public class ExamPlanServlet extends HttpServlet {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		PrintWriter out = null ;
		String result = "";
		if (request.getParameter("format")!=null) {
			if (request.getParameter("format").equals("json")) {
				response.setContentType("text/html;charset=utf-8");
				out = response.getWriter();
				if (request.getParameter("type").equals("get")) {
					
					
					Gson gson = new Gson();
					ExamPlanManager manager = new ExamPlanManager();
					result = gson.toJson(manager.getExamPlans());
				}
			}
		}
		
		out.println(result);
		out.flush();
		out.close();

	}
	
}
